CC=g++
CFLAGS=-Wall
OS=$(shell uname)
ifeq ($(OS),Windows_NT)
 OS=Windows
else
 ifneq (,$(findstring CYGWIN,$(shell uname)))
  OS=Windows
 else
  ifeq ($(OS),Darwin)
   OS=MacOS
  endif
 endif
endif
ifeq ($(OS),Windows)
 NAME=oasis.exe
else
 NAME=oasis
endif
all: main
	@echo Copying output to build/$(OS)/$(NAME)
	@mkdir -p build/$(OS)/
	@cp build/main.o build/$(OS)/$(NAME)
	@echo Finished making all
top: all
	@echo Copying output to same directory as makefile
	@cp build/main.o ./$(NAME)
	@echo Finished making ready for top
main: src/main.cpp scanner.o functions.o passone.o link
	@echo Finished building
scanner.o: src/scanner.cpp
	@echo Making scanner.o
	@$(CC) $(CFLAGS) -c src/scanner.cpp -o build/scanner.o
	@echo Finished making scanner.o
functions.o: src/functions.cpp
	@echo Making functions.o
	@$(CC) $(CFLAGS) -c src/functions.cpp -o build/functions.o
	@echo Finished making functions.o
passone.o: src/passone.cpp
	@echo Making passone.o
	@$(CC) $(CFLAGS) -c src/passone.cpp -o build/passone.o
	@echo Finished making passone.o
link:
	@echo Making main.o
	@$(CC) $(CFLAGS) src/main.cpp build/scanner.o build/passone.o build/functions.o -o build/main.o
	@echo Finished linkng
clean:
	@echo Cleaning build/ directory of files
	@rm -f build/*.*
	@rm -f ${NAME}
	@echo Finished cleaning build/
cleanall:
	@echo Cleaning build/ directory of all content
	@rm -rf build/*
	@rm -f ${NAME}
	@echo Finished cleaning build/
install: clean all
	@echo Packages cleaned and rebuilt
	@echo You might need to give your sudo password, if you have not done so already
	@sudo cp build/$(OS)/${NAME} /usr/bin/${NAME}
uninstall:
	@echo uninstalling oasis from your system
	@echo You might need to give your sudo password, if you have not done so already
	@sudo rm -f /usr/bin/${NAME}
	@echo oasis has been uninstalled